home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / PRGMANIA / BFED.10 / MAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-23  |  2.0 KB  |  127 lines

  1. /*
  2.     file: main.c
  3.     utility:
  4.     date: 1989
  5.     author: Jim Charlton
  6.     modifications:
  7.         1996: C. Moreau: 
  8.     comments: 
  9. */
  10. #include <stddef.h>
  11. #include <stdlib.h>
  12.  
  13. #ifdef __PUREC__ 
  14. #include <aes.h>
  15. #include <tos.h>
  16. #include <vdi.h>
  17. #include <compend.h>
  18. #else
  19. #include <aesbind.h>
  20. #include <osbind.h>
  21. #include <vdibind.h>
  22. #endif
  23.  
  24. #include "bufman.h"
  25. #include "events.h"
  26. #include "init.h"
  27. #include "main.h"
  28. #include "menu.h"
  29. #include "wind.h"
  30.  
  31. /*
  32.     globals vars
  33. */
  34. int gl_apid;        /* global application identifier */
  35.  
  36. /*
  37.     name: main
  38.     utility: executes initialization code and the starts the program. 
  39.     comment: 
  40.     parameters:
  41.     return: none
  42.     date: 1989
  43.     author: Jim Charlton
  44.     modifications:
  45.         1995: C.Moreau:
  46.         10 may 96: C.Moreau: reduce link to init.c: init() 
  47. */
  48. void main(int argc, char *argv[])
  49. {
  50.     /*
  51.         Initiailize the ROMs.
  52.     */
  53.     if ((gl_apid = appl_init()) != -1)
  54.     {
  55.         init(&argc, &argv);
  56.     
  57.         /*
  58.             Handle events for application.
  59.         */
  60.         TaskMaster(); 
  61.     
  62.         /*
  63.             bye...  Note: This will never be executed.
  64.         */
  65.     
  66.         shutdown(0);
  67.     }
  68. }
  69.  
  70. /*
  71.     name: shutdown
  72.     utility: is the code that closes down the application. 
  73.     comment: This routine is called when errors occurs and
  74.         guarantees that all window's will be closed properly
  75.         before exiting.
  76.     parameters:
  77.     return:
  78.     date: 1989
  79.     author: Jim Charlton
  80.     modifications:
  81.         1995: C.Moreau: 
  82. */
  83. void shutdown(int code)
  84. {
  85.     int    dummy,event;
  86.  
  87.     /*
  88.         Close down the windows.
  89.     */
  90.     while(thefrontwin)
  91.     {
  92.         dispose_buf( thefrontwin );
  93.         window_dispose(thefrontwin);
  94.     }
  95.         
  96.     /*
  97.         free cutbuffer space
  98.     */
  99.     if (cutbuffer)
  100.         free(cutbuffer);
  101.  
  102.     /*
  103.         Clean up the io buffer because of bug in TOS ?
  104.     */
  105.     do
  106.     {
  107.         event = evnt_multi( MU_TIMER|MU_KEYBD,0,0,0,
  108.             0,0,0,0,0, 0,0,0,0,0,
  109.             NULL, 1, 0,
  110.             &dummy, &dummy, &dummy, &dummy, &dummy, &dummy );
  111.     } while( event & MU_KEYBD );
  112.  
  113.     /*
  114.         Shut down the application.
  115.     */
  116.     graf_mouse(ARROW, NULL);
  117.     menu_bar(menu, MENU_REMOVE);
  118.     v_clsvwk(phys_handle);
  119.     appl_exit();
  120.  
  121.     /*
  122.         bye ...
  123.     */
  124.      exit(code);
  125. }
  126.  
  127.